<template>
    <view class="page">
        <sideslip-car ref="mycar" @selAllBtn="selAllBtn" @delBtn="delBtn" @touchEv="touchEv" class="sideslip-car"
            @selThis="selThis" @jsBtn="jsBtn" @changeNum="changeNum" :carts="cart"></sideslip-car>
    </view>
</template>
<script>
import { mapState } from "vuex";
export default {
    components: {},
    props: {},
    data() {
        return {};
    },
    computed: {
        ...mapState(["cart"]),
    },
    watch: {},
    created() { },
    methods: {
        jsBtn: async function ({ ids, nums }) {
            console.log(ids);
            console.log(nums);
            uni.navigateTo({
                url: "/pages/order/preview?ids=" + ids + "&nums=" + nums,
            });

        },
        changeNum: function (carts) {
            // this.carts = carts;
            this.$store.commit("PUSH_CART", carts)
            this.$refs.mycar.getTotalPrice();
        },
        selThis: function (carts) {
            // this.carts = carts;
            this.$store.commit("PUSH_CART", carts)
            this.$refs.mycar.getTotalPrice();
        },
        selAllBtn: function (carts) {
            // this.carts = carts;
            this.$store.commit("PUSH_CART", carts)
            this.$refs.mycar.getTotalPrice();
        },
        touchEv: function (carts) {
            this.carts = carts;
        },
        delBtn: function (carts, ids, index) {
            carts.splice(index, 1);
            this.$store.commit("PUSH_CART", carts)
            this.$refs.mycar.getTotalPrice();
        },
    },
    mounted() { },
    beforeCreate() { },
    beforeMount() { },
    beforeUpdate() { },
    updated() { },
    beforeDestroy() { },
    destroyed() { },
    activated() { },
    deactivated() { },
};
</script>
<style lang="scss" scoped></style>
